<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>题库市场 - {$site.name|htmlentities}</title>
    <link rel="shortcut icon" href="__CDN__/assets/img/favicon.ico" />
    <!-- Bootstrap Core CSS -->
    <link href="__CDN__/assets/libs/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="__CDN__/assets/css/index.css" rel="stylesheet">
    <style>
        .course-card {
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            padding: 20px;
            margin-bottom: 20px;
            transition: all 0.3s ease;
            background: #fff;
            width: 100%;
            height: 350px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            box-sizing: border-box;
        }
        .course-card:hover {
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
            transform: translateY(-2px);
        }
        .course-title {
            color: #333;
            font-size: 18px;
            font-weight: bold;
            margin-bottom: 10px;
            height: 50px;
            display: flex;
            align-items: center;
            overflow: hidden;
        }
        .course-description {
            color: #666;
            font-size: 14px;
            margin-bottom: 15px;
            line-height: 1.5;
            height: 63px;
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
        }
        .course-stats {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
            height: 60px;
        }
        .stat-item {
            text-align: center;
        }
        .stat-number {
            font-size: 16px;
            font-weight: bold;
            color: #007bff;
        }
        .stat-label {
            font-size: 12px;
            color: #999;
        }
        .difficulty-badge {
            padding: 4px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: bold;
        }
        .difficulty-easy {
            background: #d4edda;
            color: #155724;
        }
        .difficulty-medium {
            background: #fff3cd;
            color: #856404;
        }
        .difficulty-hard {
            background: #f8d7da;
            color: #721c24;
        }
        .category-tag {
            background: #007bff;
            color: white;
            padding: 2px 8px;
            border-radius: 10px;
            font-size: 12px;
            margin-right: 5px;
        }
        .search-section {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            padding: 60px 0;
            color: white;
        }
        .search-box {
            max-width: 600px;
            margin: 0 auto;
        }
        .search-input {
            border-radius: 25px;
            padding: 15px 20px;
            border: none;
            font-size: 16px;
            height: 50px;
        }
        .search-btn {
            border-radius: 25px;
            padding: 15px 30px;
            border: none;
            background: #28a745;
            color: white;
            font-weight: bold;
            height: 50px;
            line-height: 20px;
        }
        .search-btn:hover {
            background: #218838;
            color: white;
        }
        .section-title {
            font-size: 24px;
            font-weight: bold;
            margin-bottom: 30px;
            text-align: center;
            color: #333;
        }
        .row {
            display: flex;
            flex-wrap: wrap;
        }
        .col-md-6.col-lg-4 {
            display: flex;
            width: 33.333333%;
            padding: 0 15px;
            margin-bottom: 30px;
        }
        .no-results {
            text-align: center;
            padding: 40px;
            color: #666;
        }
    </style>
</head>

<body>
    <nav id="mainNav" class="navbar navbar-default navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-menu">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand page-scroll" href="{:url('/')}">{$site.name|htmlentities}</a>
            </div>

            <div class="collapse navbar-collapse" id="navbar-collapse-menu">
                <ul class="nav navbar-nav navbar-right">
                    <li><a href="{:url('/')}">首页</a></li>
                    <li><a href="{:url('/index/course/index')}">题库市场</a></li>
                    <li><a href="{:url('/user/index/index')}">创作中心</a></li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 搜索区域 -->
    <section class="search-section">
        <div class="container">
            <div class="text-center">
                <h1 style="margin-bottom: 20px;">题库市场</h1>
                <p style="font-size: 18px; margin-bottom: 40px;">海量题库，助力考试成功</p>
                
                <form method="get" action="{:url('/index/course/index')}" class="search-box">
                    <div class="input-group">
                        <input type="text" name="keyword" class="form-control search-input" 
                               placeholder="请输入题库名称或编码检索" value="{$keyword}">
                        <span class="input-group-btn">
                            <button class="btn search-btn" type="submit">
                                <i class="fa fa-search"></i> 搜索
                            </button>
                        </span>
                    </div>
                </form>
            </div>
        </div>
    </section>

    <main style="padding: 60px 0; background: #f8f9fa;">
        <div class="container">
            {if $hasSearch}
            <!-- 搜索结果 -->
            <div class="section-title">搜索结果："{$keyword}"</div>
            {if $searchResults}
            <div class="row">
                {volist name="searchResults" id="course"}
                <div class="col-md-6 col-lg-4">
                    <div class="course-card">
                        <div class="course-title">{$course.title}
                            {if $course.code}
                            <small style="color: #999; font-size: 12px; font-weight: normal; margin-left: 8px;">({$course.code})</small>
                            {/if}
                        </div>
                        <div class="course-description">{$course.description}</div>
                        
                        <div class="course-stats">
                            <div class="stat-item">
                                <div class="stat-number">{$course.question_count}</div>
                                <div class="stat-label">题目数</div>
                            </div>
                            <div class="stat-item">
                                <div class="stat-number">{$course.study_count}</div>
                                <div class="stat-label">学习人数</div>
                            </div>
                            <div class="stat-item">
                                <span class="difficulty-badge difficulty-{$course.difficulty|lower}">{$course.difficulty}</span>
                            </div>
                        </div>
                        
                        <div style="margin-bottom: 15px;">
                            <span class="category-tag">{$course.category}</span>
                        </div>
                        
                        <div class="text-center">
                            <a href="#" class="btn btn-primary btn-sm">开始练习</a>
                            <a href="#" class="btn btn-outline-secondary btn-sm">查看详情</a>
                        </div>
                    </div>
                </div>
                {/volist}
            </div>
            {else}
            <div class="no-results">
                <h4>未找到相关题库</h4>
                <p>请尝试其他关键词或浏览下方热门题库</p>
            </div>
            {/if}
            
            <hr style="margin: 50px 0;">
            {/if}
            
            <!-- 题目动态和热门题库并排显示 -->
            <div class="row">
                <!-- 左侧：题目动态 -->
                <div class="col-md-4">
                    <div class="section-title">题目动态</div>
                    <div class="dynamics-container" style="background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 40px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); height: 600px; overflow-y: auto;">
                        {volist name="questionDynamics" id="dynamic"}
                        <div class="dynamic-item" style="padding: 15px 0; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center;">
                            <div class="dynamic-avatar" style="width: 35px; height: 35px; background: linear-gradient(45deg, #007bff, #0056b3); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; margin-right: 12px; font-size: 12px;">
                                {$dynamic.user_name|substr=0,1}
                            </div>
                            <div class="dynamic-content" style="flex: 1;">
                                <div class="dynamic-text" style="color: #333; font-size: 13px; margin-bottom: 5px; line-height: 1.4;">
                                    <strong>{$dynamic.user_name}</strong> 上传了题目<br>
                                    <a href="{$dynamic.detail_url}" style="color: #007bff; font-weight: 500; text-decoration: none;" target="_blank">{$dynamic.question_title}</a>
                                    {if $dynamic.course_name}
                                    <span style="color: #999; font-size: 11px; margin-left: 5px;">({$dynamic.course_name})</span>
                                    {/if}
                                </div>
                                <div class="dynamic-time" style="color: #999; font-size: 11px;">
                                    {$dynamic.upload_time}
                                </div>
                            </div>
                        </div>
                        {/volist}
                        <div class="text-center" style="margin-top: 15px;">
                            <a href="#" class="btn btn-link" style="color: #007bff; font-size: 13px;">查看更多动态 →</a>
                        </div>
                    </div>
                </div>
                
                <!-- 右侧：热门题库 -->
                <div class="col-md-8">
                    <div class="section-title">热门题库</div>
                    <div class="row">
                        {volist name="hotCourses" id="course"}
                        <div class="col-md-6">
                            <div class="course-card" style="height: 280px;">
                                <div class="course-title" style="height: 45px; font-size: 16px;">{$course.title}
                                    {if $course.code}
                                    <small style="color: #999; font-size: 11px; font-weight: normal; margin-left: 6px;">({$course.code})</small>
                                    {/if}
                                </div>
                                <div class="course-description" style="height: 55px; font-size: 13px;">{$course.description}</div>
                                
                                <div class="course-stats" style="height: 50px;">
                                    <div class="stat-item">
                                        <div class="stat-number" style="font-size: 16px;">{$course.question_count}</div>
                                        <div class="stat-label" style="font-size: 11px;">题目数</div>
                                    </div>
                                    <div class="stat-item">
                                        <div class="stat-number" style="font-size: 16px;">{$course.study_count}</div>
                                        <div class="stat-label" style="font-size: 11px;">学习人数</div>
                                    </div>
                                    <div class="stat-item">
                                        {switch name="course.difficulty"}
                                        {case value="简单"}
                                        <span class="difficulty-badge difficulty-easy" style="font-size: 11px; padding: 2px 6px;">{$course.difficulty}</span>
                                        {/case}
                                        {case value="中等"}
                                        <span class="difficulty-badge difficulty-medium" style="font-size: 11px; padding: 2px 6px;">{$course.difficulty}</span>
                                        {/case}
                                        {case value="困难"}
                                        <span class="difficulty-badge difficulty-hard" style="font-size: 11px; padding: 2px 6px;">{$course.difficulty}</span>
                                        {/case}
                                        {/switch}
                                    </div>
                                </div>
                                
                                <div style="margin-bottom: 12px;">
                                    <span class="category-tag" style="font-size: 11px; padding: 3px 8px;">{$course.category}</span>
                                </div>
                                
                                <div class="text-center">
                                    <a href="#" class="btn btn-primary btn-sm" style="font-size: 12px; padding: 6px 12px;">开始练习</a>
                                    <a href="#" class="btn btn-outline-secondary btn-sm" style="font-size: 12px; padding: 6px 12px;">查看详情</a>
                                </div>
                            </div>
                        </div>
                        {/volist}
                    </div>
                </div>
            </div>
        </div>
    </main>

    <!-- Footer -->
    <footer style="background: #333; color: white; padding: 40px 0; text-align: center;">
        <div class="container">
            <p>&copy; 2024 {$site.name|htmlentities}. All rights reserved.</p>
        </div>
    </footer>

    <!-- jQuery -->
    <script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap Core JavaScript -->
    <script src="__CDN__/assets/libs/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- Font Awesome -->
    <link href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

</body>

</html>